﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Aspfm.Html
{
    [Serializable()]
    public class AspfmParams : System.Runtime.Serialization.SerializationBinder
    {
        public string strKey = "";
        public string CodeMain = "";

        public override Type BindToType(string assemblyName, string typeName)
        {
            return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName));
        }
    }

    [Serializable()]
    public class AspfmDataSource : System.Runtime.Serialization.SerializationBinder
    {
        public string strKey = "";
        public List<AspfmDataSql> sqlList = new List<AspfmDataSql>();
        public List<AspfmExecSql> execList = new List<AspfmExecSql>();
        public List<AspfmUpdateSql> UpdateList = new List<AspfmUpdateSql>();
        public List<AspfmProcSql> procList = new List<AspfmProcSql>();

        public AspfmDataSource Copy()
        {
            AspfmDataSource ads = new AspfmDataSource();
            foreach (AspfmDataSql adsql in sqlList)
            {
                ads.sqlList.Add(adsql.Copy());
            }
            foreach (AspfmExecSql adexe in execList)
            {
                ads.execList.Add(adexe.Copy());
            }
            foreach (AspfmUpdateSql adupd in UpdateList)
            {
                ads.UpdateList.Add(adupd.Copy());
            }
            foreach (AspfmProcSql adproc in procList)
            {
                ads.procList.Add(adproc.Copy());
            }
            ads.strKey = strKey;
            return ads;
        }
        public override Type BindToType(string assemblyName, string typeName)
        {
            return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName));
        }
    }

    [Serializable()]
    public class AspfmDataSql : System.Runtime.Serialization.SerializationBinder
    {
        public string strKey = "";
        public string SqlStr = "";
        public string columns = "";
        public string Htmlstr = "";
        public string orderby = "";
        public int CacheTime = 0;
        public bool IsSimpleSql = false;
        public string rightCode = "";

        public AspfmDataSql Copy()
        {
            AspfmDataSql aspfm = new AspfmDataSql();
            aspfm.strKey = strKey;
            aspfm.SqlStr = SqlStr;
            aspfm.columns = columns;
            aspfm.Htmlstr = Htmlstr;
            aspfm.orderby = orderby;
            aspfm.CacheTime = CacheTime;
            aspfm.IsSimpleSql = IsSimpleSql;
            aspfm.rightCode = rightCode;
            return aspfm;
        }

        public override Type BindToType(string assemblyName, string typeName)
        {
            return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName));
        }
    }

    [Serializable()]
    public class AspfmUpdateSql : System.Runtime.Serialization.SerializationBinder
    {
        public string strKey = "";
        public string tablename = "";
        public string columns = "";
        public string pkCol = "";
        public bool IsInsert = true;
        public string rightCode = "";
        public Dictionary<string, string> ColList = new Dictionary<string, string>();

        public AspfmUpdateSql Copy()
        {
            AspfmUpdateSql aspfm = new AspfmUpdateSql();
            aspfm.strKey = strKey;
            aspfm.tablename = tablename;
            aspfm.columns = columns;
            aspfm.pkCol = pkCol;
            aspfm.IsInsert = IsInsert;
            aspfm.rightCode = rightCode;
            foreach (string key in ColList.Keys)
            {
                aspfm.ColList.Add(key, ColList[key]);
            }
            return aspfm;
        }

        public override Type BindToType(string assemblyName, string typeName)
        {
            return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName));
        }
    }

    [Serializable()]
    public class AspfmExecSql : System.Runtime.Serialization.SerializationBinder
    {
        public string strKey = "";
        public string SqlStr = "";
        public string rightCode = "";

        public AspfmExecSql Copy()
        {
            AspfmExecSql aspfm = new AspfmExecSql();
            aspfm.strKey = strKey;
            aspfm.SqlStr = SqlStr;
            aspfm.rightCode = rightCode;
            return aspfm;
        }

        public override Type BindToType(string assemblyName, string typeName)
        {
            return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName));
        }
    }
    [Serializable()]
    public class AspfmProcSql : System.Runtime.Serialization.SerializationBinder
    {
        public string strKey = "";
        public string SqlStr = "";
        public bool isWart = true;
        public string Js = "";
        public bool isQuery = false;
        public int CacheTime = 0;
        public string rightCode = "";

        public AspfmProcSql Copy()
        {
            AspfmProcSql aspfm = new AspfmProcSql();
            aspfm.strKey = strKey;
            aspfm.SqlStr = SqlStr;
            aspfm.isWart = isWart;
            aspfm.Js = Js;
            aspfm.isQuery = isQuery;
            aspfm.CacheTime = CacheTime;
            aspfm.rightCode = rightCode;
            return aspfm;
        }

        public override Type BindToType(string assemblyName, string typeName)
        {
            return Type.GetType(String.Format("{0}, {1}", typeName, assemblyName));
        }
    }
}
